<script src="__PUBLIC__/js/jquery-1.7.2.js" type="text/javascript"></script>
<div id="head">
	<div class="topBox">
		<div class="float_left linkStyle1">
		<if condition="$account">
		<div id="loginInfo">
			<span class="fontStyle1" id="name">您好：<a href="__APP__/User/main">{$account}</a></span>
			<span class="fontStyle1"><a href="__APP__/Public/doLogout/url/{$url}">[退出]</a></span>
		</div>
		<else/>
		<form action="__APP__/Public/doLogin" method="POST" id="loginForm">
			<span class="fontStyle1">用户名</span><input class="input1" type="text" name="account" id="account"/>
			<span class="fontStyle1">密码</span><input class="input1" type="password" name="pwd" id="pwd"/>
			<input type="hidden" name="url" value="{$url}" />
			<input class="button1" type="button" value="登  录" id="loginBtn"/>
			<a href="__APP__/Public/register" target="_blank">新用户注册</a>
		</form>	
		</if>	
		</div>
		<div class="float_right fontStyle1">
			<span class="fontStyle1">收藏本站</span> | 
			<span class="fontStyle1">关于本站</span> | 
			<span class="fontStyle1">联系站长</span> | 
			<span class="fontStyle1"><a href="__APP__/Index" target="_self">返回首页</a></span>
		</div>
	</div>
</div>

<script type="text/javascript">
$("#account").val(" ");

$("#loginBtn").click(function(){
	doLogin();
});

//回车事件
$(function(){
document.onkeydown = function(e){
    var ev = document.all ? window.event : e;
  	if (ev.keyCode == 13)
  		doLogin();
}
}); 

$("#account").bind('click',function(){
	$(this).css({color:"#000000"});	
});

$("#pwd").bind('click',function(){
	$(this).css({color:"#000000"});	
});

function doLogin() {
	var account = $("#account").val().trim();
	var pwd = $("#pwd").val().trim();
	if (account == '' || account == null) {
		$("#account").focus().css({color:"red"});
		return ;
	}
		
	if (pwd == '' || pwd == null) {
		$("#pwd").focus().css({color:"red"});
		return ;
	}
	
	$.post(
			"__APP__/Public/doLogin",
			{account:account, pwd:pwd},
			function(result){
				var data = $.parseJSON(result);
				if (data.ret) {
					window.location.reload();
				} else {
					alert(data.errMsg);
				}
			}
		);
}

</script>



